import Vue from 'vue'
import Vuex from 'vuex'
import {getPersonalInfo} from '../api/api'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse: false,
    userInfo: {}
  },
  mutations: {
    receive_user(state, userInfo) {
      state.userInfo = userInfo
    },
  },
  actions: {
    async getUser({commit}) {
      const res = await getPersonalInfo()
      commit('receive_user', res.data)
      return {userInfo: res.data}
    },
  },
  modules: {}
})
